<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
		<link rel="stylesheet" href="layui/css/layui.css">
		<script src= "layui/layui.js"></script>
		<script  src= "mods/layarea.js"></script>
		<title>信息修改</title>
	</head>
	<body>
	<div class="layui-container">
		<div class="layui-row" >
	<div class='layui-col-md10'>
	<form class="layui-form" action=""  id='modifyform' lay-filter="modify">
		
		  <div class="layui-form-item">
		    <label class="layui-form-label">企业名称</label>
		    <div class="layui-input-inline">
		      <input type="text" name="ename"
			  required  lay-verify="required" placeholder="请输入企业名称" 
			  autocomplete="on" class="layui-input" lay-verType="alert">
		    </div>
		  </div>
	
		  
	
		  <div class="layui-form-item">
			 
		    <label class="layui-form-label">企业联系人</label>
		    <div class="layui-input-inline">
		      <input type="text" name="contacts" 
			  required lay-verify="required" placeholder="请输入联系人姓名" 
			  autocomplete="on" class="layui-input" lay-verType="alert">
		    </div>
		  </div>

			 

		  <div class="layui-form-item">
		    <label class="layui-form-label">联系电话</label>
		    <div class="layui-input-inline">
		      <input type="text" name="telephone" 
		  			  required lay-verify="required" placeholder="请输入联系电话" 
					  autocomplete="on" class="layui-input" lay-verType="alert">
		    </div>
		  </div>
		 
		  <div class="layui-form-item">
		    <label class="layui-form-label">企业邮箱</label>
		    <div class="layui-input-inline">
		      <input type="text" name="email" 
		  			  required lay-verify="required|email" placeholder="请输入企业邮箱" 
					  autocomplete="on" class="layui-input" lay-verType="alert">
		    </div>
		  </div>
		  
		  <div class="layui-form-item">
		    <label class="layui-form-label">企业网址</label>
		    <div class="layui-input-inline">
		      <input type="text" name="website" 
		  			  required lay-verify="required" placeholder="请输入企业网址"
					   autocomplete="on" class="layui-input"  lay-verType="alert">
		    </div>
		  </div>
		  
		   <div class="layui-form-item" id="area-picker">
		       <div class="layui-form-label">企业地址</div>
		            <div class="layui-input-inline" style="width: 200px;" autocomplete="on"  data-value='山东省' lay-filter="province-1">
		                <select name="province" class="province-selector" >
		                    <option value="">请选择省</option>
		                </select>
		            </div>
		            <div class="layui-input-inline" style="width: 200px;"autocomplete="on" data-value='泰安市' lay-filter="city-1" >
		                <select name="city" class="city-selector">
		                    <option value="">请选择市</option>
		                </select>
		            </div>
		            <div class="layui-input-inline" style="width: 200px;"autocomplete="on" data-value='泰山区' lay-filter="county-1">
		                <select name="area" class="county-selector" >
		                    <option value="">请选择区</option>
		                </select>
		           </div> 
		        </div>
		<div class='layui-form-item'>
			<label class="layui-form-label">详细地址</label>
			<div class='layui-input-block'>
			<input type="text" name="address"
			lay-verify="required" placeholder="请输入企业详细地址"
			autocomplete="on" class="layui-input"  lay-verType="alert">
			</div>
		</div>
	
		  <div class="layui-form-item">
		    <label class="layui-form-label">企业性质</label>
		    <div class="layui-input-inline">
		      <select name="type" lay-verify="required" autocomplete="on">
		        <option value=""></option>
		        <option value="国有企业">国有企业</option>
		        <option value="民营企业">民营企业</option>
		        <option value="外资企业">外资企业</option>
				  <option value="中外合资">中外合资</option>
		        <option value="其他类型企业">其他类型企业</option>
		      </select>
		    </div>
		  </div>
		  
		  <div class="layui-form-item">
		    <label class="layui-form-label">企业类型</label>
		    <div class="layui-input-inline">
		    <select name="organize" lay-verify="required" autocomplete="on">
		      <option value=""></option>
		      <option value="500强">500强</option>
		      <option value="上市公司">上市公司</option>
		      <option value="龙头企业">龙头企业</option>
			  <option value="知名企业">知名企业</option>
		      <option value="其他类型企业">其他类型企业</option>
		    </select>
		    </div>
		  </div>

		  <div class='layui-form-item'>
		  	<label class="layui-form-label">注册资金</label>
		  	<div class='layui-input-inline'>
		  	<input type="text" name="capital" lay-verify="required" placeholder="请输入企业的注册资金(万元)"
		  	autocomplete="on" class="layui-input"  lay-verType="alert">
			 <span style=" position: absolute; top: 8%; right: 6%; display: table-cell;background-color: #FFFFFF;
			  white-space: nowrap; padding: 7px 10px;">万元</span>
		  </div>
		  </div>

		<div class='layui-form-item'>
			<div class='layui-input-inline'>
				<input type="text" name="license" lay-verify="required"
					   style="display: none" autocomplete="on" class="layui-input"  lay-verType="alert" lay-reqText="请上传营业执照后再修改">
			</div>
		</div>
		 
		  <div class="layui-form-item">
		    <div class="layui-input-block">
		      <button class="layui-btn" lay-submit lay-filter="formDemo">提交</button>
		      <button type="button" class="layui-btn layui-btn-primary" onclick="window.history.go(-1)">返回</button>
		    </div>
		  </div>

		</form>
		</div>
	</div>
</div>
<script type="text/javascript">
	//插件的目录配置
   layui.config({
		    base: '/mods/'
			});
   //从后端调用的数据在前端进行显示。
   layui.use(['form','layer','layarea'],function(){
	  var form = layui.form,
	  layer=layui.layer,
	  layarea=layui.layarea;
	  var $=layui.$;
	  $.ajax({ //在信息的编辑界面的
		  type:"post",
		  async:false,
		  url:"/enter/viewInfo",
		  success:function (data){
		  	var obj=JSON.parse(data);
		  	var enterprise=obj.data.enterprise;
			  form.val('modify',{
				  "ename":enterprise.ename//用来测试用的字段
				  ,"telephone":enterprise.telephone
				  ,"email":enterprise.email
				  ,"contacts":enterprise.contacts
				  ,"website":enterprise.website
				  ,"province":enterprise.province
				  ,"city":enterprise.city
				  ,"area":enterprise.area
				  ,"address":enterprise.address
				  ,"type":enterprise.type
				  ,"organize":enterprise.organize
				  ,"capital":enterprise.capital,
				  "license":enterprise.license


			  });
		  }
	  });
	  // form.val('modify',{
		//   "ename": "煤炭公司"
		//   ,"telephone": "0534-8241222"
		//   ,"email": "mzd19971122@126.com"
		//   ,"contacts": "马先生"
		//   , "need":120
		//   , "website":"www.test.com"
		//   ,"province":370000
		//   ,"city":370900
		//   ,"county":370902
		//   ,"detail_add":'岱宗大街61号'
		//   ,"type":"其他类型企业"
		//   ,"epprop":"知名企业",
		//   "res-rmb":2000
		//
	  // });
	  layarea.render({
	      elem: '#area-picker',
	      change: function (res) {
	          //选择结果
	          console.log(res);
			   // form.render();
	      }
	  });
	  var data1=form.val('modify');
	  //监听提交，将修改后的数据进行的提交操作，
	  form.on('submit(formDemo)', function(data){//data来自表格的填充数据
		  // layer.msg(data.field);
	    $.ajax({
			type:'post',
			cache:false,
			dataType:'json',
			url:'/enter/modifyInfo',
			async:false,
			data:data.field,
			success:function (ret){
				console.log(ret);
				if(ret.code===200){
					layer.msg('修改成功',function (){
						window.location.href='main.html';
						window.location.reload();


					});
				}else{
					layer.msg('修改失败');
				}
			},
			error:function(){
				layer.msg('操作失败，请检查');
			}


		})
		  form.render();
	    return false;
	
	  });
	
	});
	

	</script>

	<style type="text/css">
			.layui-form-item .layui-input-inline{
				width:300px;
			}
	
		
			</style>
<script>
		    //配置插件目录
		    layui.config({
		        base: '/mods/'
		        , version: '1.0'
		    });
		    //一般直接写在一个js文件中
		    layui.use(['layer', 'form', 'layarea'], function () {
		        var layer = layui.layer
		            , form = layui.form
		            , layarea = layui.layarea;
		
		        layarea.render({
		            elem: '#area-picker',
		            change: function (res) {
		                //选择结果
		                console.log(res);
		            }
		        });
		    });
		</script>
		
		
		
	</body>
	
	
	
</html>
